package com.irdstudio.efp.flow.service.impl;

import com.irdstudio.efp.flow.service.dao.BizFlowEngineInquireDao;
import com.irdstudio.efp.flow.service.domain.FlowInfoInquire;
import com.irdstudio.efp.flow.service.facade.BizFlowEngineInquireService;
import com.irdstudio.efp.flow.service.vo.DashBoardFlowVO;
import com.irdstudio.efp.flow.service.vo.PageInquireInVO;
import com.irdstudio.efp.flow.service.vo.PageInquireOutVO;
import com.irdstudio.basic.framework.core.base.FrameworkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * 流程引擎查询
 * 
 * @author Cytus_
 * @since 2018年5月12日 上午11:05:59
 * @version 1.0
 *
 */
@SuppressWarnings("unchecked")
@Service("bizFlowEngineInquireService")
public class BizFlowEngineInquireServiceImpl implements BizFlowEngineInquireService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(BizFlowEngineInquireServiceImpl.class);
	
	@Autowired
	private BizFlowEngineInquireDao bizFlowEngineInquireDao;

	/**
	 * 待办
	 */
	public List<PageInquireOutVO> waitDoneOwner(PageInquireInVO inVo) {
		logger.debug("查询本人待办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.waitDoneOwnerByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本人待办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人待办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 待办
	 */
	public List<PageInquireOutVO> waitDoneCurrOrg(PageInquireInVO inVo) {
		logger.debug("查询本机构待办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.waitDoneCurrOrgByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本机构待办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本机构待办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 待办
	 */
	public List<PageInquireOutVO> waitDoneCurrDownOrg(PageInquireInVO inVo) {
		logger.debug("查询本机构及下属机构待办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.waitDoneCurrDownOrgByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本机构及下属机构待办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本机构及下属机构待办事项出现异常!", e);
		}
		return outVos;
	}

	@Override
	public List<DashBoardFlowVO> dashBoardFlow(PageInquireInVO inVo) {
		logger.debug("查询本人主页待办事项开始.....");
		List<DashBoardFlowVO> outVos = null;
		try {
			List<DashBoardFlowVO> infos = bizFlowEngineInquireDao.dashBoardFlow(inVo);
			pageSet(infos, inVo);
			outVos = (List<DashBoardFlowVO>) beansCopy(infos, DashBoardFlowVO.class);
			logger.debug("查询本人主页待办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人主页待办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 已办
	 */
	public List<PageInquireOutVO> haveDoneOwner(PageInquireInVO inVo) {
		logger.debug("查询本人已办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.haveDoneOwnerByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本人已办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人已办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 已办
	 */
	public List<PageInquireOutVO> haveDoneCurrOrg(PageInquireInVO inVo) {
		logger.debug("查询本机构已办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.haveDoneCurrOrgByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本机构已办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本机构已办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 已办
	 */
	public List<PageInquireOutVO> haveDoneCurrDownOrg(PageInquireInVO inVo) {
		logger.debug("查询本人已办事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.haveDoneCurrDownOrgByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本人已办事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人已办事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 办结
	 */
	public List<PageInquireOutVO> endDoneOwner(PageInquireInVO inVo) {
		logger.debug("查询本人办结事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.endDoneOwnerByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本人办结事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人办结事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 办结
	 */
	public List<PageInquireOutVO> endDoneCurrOrg(PageInquireInVO inVo) {
		logger.debug("查询本机构办结事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.endDoneCurrOrgByPage(inVo); 
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本机构办结事项结束.....");
		} catch (Exception e) {
			logger.error("查询本机构办结事项出现异常!", e);
		}
		return outVos;
	}

	/**
	 * 办结
	 */
	public List<PageInquireOutVO> endDoneCurrDownOrg(PageInquireInVO inVo) {
		logger.debug("查询本人办结事项开始.....");
		List<PageInquireOutVO> outVos = null;
		try {
			List<FlowInfoInquire> infos = bizFlowEngineInquireDao.endDoneCurrDownOrgByPage(inVo);
			pageSet(infos, inVo);
			outVos = (List<PageInquireOutVO>) beansCopy(infos, PageInquireOutVO.class);
			logger.debug("查询本人办结事项结束.....");
		} catch (Exception e) {
			logger.error("查询本人办结事项出现异常!", e);
		}
		return outVos;
	}

}
